//
//  fGGoodsTableViewCell.m
//  fGeekApp
//
//  Created by Administrator on 15/3/9.
//  Copyright (c) 2015年 cwx. All rights reserved.
//

#import "fGGoodsTableViewCell.h"
#import "UIImageView+AFNetworking.h"

@interface fGGoodsTableViewCell()
@property (weak, nonatomic) IBOutlet UIImageView *goodsIconView;
@property (weak, nonatomic) IBOutlet UILabel *goodsNameLable;
@property (weak, nonatomic) IBOutlet UILabel *goodsContentLable;
@property (weak, nonatomic) IBOutlet UILabel *goodsPriceLable;
@property (weak, nonatomic) IBOutlet UILabel *goodsSaleCountLable;
@property (weak, nonatomic) IBOutlet UILabel *goodsAddressLable;

@end

@implementation fGGoodsTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"goodsCell";
    fGGoodsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    return cell;
}

-(void)setGoods:(Goods *)goods{
    _goods = goods;
    
    //1.名称
    self.goodsNameLable.text = goods.goodsName;
    
    //2.详情
    self.goodsContentLable.text = goods.goodsContentBody;
    
    //3.价格
    self.goodsPriceLable.text = [NSString stringWithFormat:@"$%.2f",goods.goodsPrice];
    
    //4.购买数
    self.goodsSaleCountLable.text = [NSString stringWithFormat:@"以售%d笔",goods.goodsSaleCount];
    
    //5.地址
    self.goodsAddressLable.text = [NSString stringWithFormat:@"地点:%@",goods.goodsAddress];
    
    //6.图片
//    self.goodsIconView.image = [UIImage imageNamed:goods.goodsImagePath];
    //方法一：使用AFN提供的UIImageView的扩展，异步加载每一行的图片
    //当数据库没图片的时候，默认给一张图片 default.png
    NSString *urlPath = [NSString stringWithFormat:@"%@%@",kHTTPImg,goods.goodsImagePath];
    [self.goodsIconView setImageWithURL:[NSURL URLWithString:urlPath] placeholderImage:[UIImage imageNamed:@"default.png"]];
    
    
}


@end
